import { ConfigType, registerAs } from '@nestjs/config'

import { env, envBoolean, envNumber } from '@/utils/env'

export const appRegToken = 'app'

export const AppConfig = registerAs(appRegToken, () => ({
	name: env('APP_NAME'),
	port: envNumber('APP_PORT', 3000),
	baseUrl: env('APP_BASE_URL'),
	globalPrefix: env('GLOBAL_PREFIX', '/'),
	locale: env('APP_LOCALE', 'zh-CN'),
	captchaEnabled: envBoolean('CAPTCHA_ENABLED', true),
	AESSecretKey: env('AES_SECRET_KEY'),
}))

export type IAppConfig = ConfigType<typeof AppConfig>
